//
//  RCDScrollView.m
//  BaseProject
//
//  Created by 任辰东 on 2018/7/11.
//  Copyright © 2018年 任辰东. All rights reserved.
//

#import "RCDScrollView.h"

@implementation RCDScrollView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.alwaysBounceVertical = YES;
        _contentView = [UIView new];
        [self addSubview:_contentView];
        
        [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
            //必须要约束宽度
            make.width.equalTo(self.mas_width);
//            make.height.equalTo(self.mas_height).priorityLow();
        }];
//        [self addSingleTap];
    }
    return self;
}
- (void)addSingleTap
{
    self.contentView.userInteractionEnabled = YES;
    UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleSingleTap:)];
    singleTapGesture.numberOfTapsRequired =1;
    singleTapGesture.numberOfTouchesRequired  =1;
    [self.contentView addGestureRecognizer:singleTapGesture];
}

-(void)handleSingleTap:(UIGestureRecognizer *)sender
{
    if (self.singleTap) {
        self.singleTap();
    }
}

@end
